package com.glenet.salary.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;

import com.glenet.salary.entities.HrPreFee;
import com.glenet.salary.util.SessionFactoryUtil;

public class HrPreFeeDao extends HrDaoSuport {

	public int batchImport(List<HrPreFee> list) {
		int effect = 0;
		try {
			SqlSession session = SessionFactoryUtil.getSessionFactory().openSession(ExecutorType.BATCH);
			for (HrPreFee preFee : list) {
				session.insert("HrPreFee.batchImport", preFee);
			}
			session.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return effect;
	}

	@SuppressWarnings("unchecked")
	public List<HrPreFee> list(int offset, int limit) {
		List<HrPreFee> list = new ArrayList<HrPreFee>();
		try {
			SqlSession session = SessionFactoryUtil.openSession();
			list = (List<HrPreFee>) session.selectList("HrPreFee.select");
			session.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	public List<HrPreFee> list(long companryId, int offset, int limit) {

		return null;
	}

}
